package com.liukai.bishe.ui.dialog;

import android.app.AlertDialog;
import android.content.Context;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.TextView;

import com.liukai.bishe.R;
import com.liukai.bishe.model.doman.transaction.TransactionUseTime;
import com.liukai.bishe.presenter.transactionPresenter.ITransactionPresenter;
import com.liukai.bishe.ui.activity.CountDownActivity;
import com.liukai.bishe.utils.DateUtils;
import com.liukai.bishe.utils.ToastUtil;

import java.text.SimpleDateFormat;
import java.util.Date;

public class DownTransactionDialog {

    private final CountDownActivity mCountDownActivity;
    private Context mContext;
    private AlertDialog mDialog = null;
    private TextView mBtnStopCount;
    private TextView mBtnCancel;
    private TextView mBtnCancelCount;
    private String mTime = "0";

    private ITransactionPresenter mITransactionPresenter;

    private TransactionUseTime mTransactionUseTime;

    public DownTransactionDialog(Context context, ITransactionPresenter iTransactionPresenter,
                                 TransactionUseTime transactionUseTime, CountDownActivity countDownActivity) {
        mContext = context;
        this.mITransactionPresenter = iTransactionPresenter;
        this.mTransactionUseTime = transactionUseTime;
        this.mCountDownActivity = countDownActivity;

        View mView_dialog = View.inflate(mContext, R.layout.dialog_stop_transaction,null);
        if (mDialog == null){
            // 创建AlertDialog对象
            mDialog = new AlertDialog.Builder(mContext).create();
            mDialog.show();
            // 设置点击可取消
            mDialog.setCancelable(true);
            // 获取Window对象
            Window window = mDialog.getWindow();
            window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
            window.clearFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE|WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM);
            // 设置显示视图内容
            window.setContentView(mView_dialog);

//            WindowManager.LayoutParams lp = mDialog.getWindow().getAttributes();
//            lp.width = 500;// 调整该值可以设置对话框显示的宽度
//            lp.height = ViewGroup.LayoutParams.WRAP_CONTENT;
//            window.setAttributes(lp);
        }else {
            mDialog.show();
        }

        initView();
        initListener();
    }

    private void initListener() {


    }

    private void initView() {


    }

    public void show(){
        mDialog.setCanceledOnTouchOutside(false);
//        mDialog.show();
    }


    public void setTime(String string) {
        this.mTime = string;
    }
}
